#{extends 'main.html' /} #{set title:'Home' /}
<!-- @author Heidi eltoukhy
this page retrieves a list with all the community lists that either the registeredUser joined or created with two options either it "Leave" it or
"Open" it to retrieve its members-->
<body>

	<li><a href="@{CommunityLists.createCommListPage()}">Create
			New Community List </a></li>
	<p
		style="background-color: #FF6600; width: 400px; text-align: center; font-size: 20px;">
		<i>My Community Lists:</i>
	</p>

	#{ifnot ListPage2}
	<p
		style="background-color: #778899; width: 300px; text-align: top; font-size: 20px;">
		You Aren't A Memember In Any CommunityLists !!</p>
	#{/ifnot} #{if !ListPage2.empty}
	<table width="300" id="dataTable" background="lightblue" ; border="2"
		; BORDERCOLOR=#FF6600>
		<tr>
			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Joined CommunityLists Title</p></th>
			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Action</p></th>

			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Action</p></th> #{list items:ListPage2,as:'jList'}
		</tr>
		<td>
			<ul>
				<li>
					<h2>${jList.name}</h2>
				</li>
			</ul> ${jList.id}</td>
		<!-- Begin @author Heidi ElToukhy a button to open a certain communityList and
			view a list of its members"-->
		<td>

			<form action="@{CommunityLists.commListContent()}" method="GET">
				<div id="${jList.id}">
					<button name="Open" type="submit" value="${jList.id}">Open</button>

				</div>
				<hr>
			</form>
		</td>
		<!-- End @author Heidi ElToukhy-->
		<td>
			<!-- Begin @author Nada the button is added if the user is not a member in others commList or he is not the creator -->
			#{if isReg == false } #{if
			!(models.RegisteredUser.findById(Long.parseLong(session.get("RegisteredUserId"))).CommunityLists.contains(models.CommunityList.findById(jList.id)))}
			#{if
			models.RegisteredUser.findById(Long.parseLong(session.get("RegisteredUserId")))
			!= models.CommunityList.findById(jList.id).creator}
			<form action="@{CommunityLists.askToJoin()}" method="GET">
				<div id="${jList.id}">
					<button name="join" type="submit" value="${jList.id}">ask
						to join</button>
				</div>

			</form> #{/if} #{/if} #{/if} <!-- End @author Nada-->
		</td> #{/list}
	</table>

<p
		style="background-color: #FF6600; width: 400px; text-align: center; font-size: 20px;">
		</p>
	#{/if} #{ifnot ListPage}
	<p
		style="background-color: #778899; width: 300px; text-align: top; font-size: 20px;">
		You Haven't Created Any CommunityLists !!</p>
	#{/ifnot} #{if !ListPage.empty}
	<table width="300" id="dataTable" background="lightblue" ; border="2"
		; BORDERCOLOR=#FF6600>
		<tr>
			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Created CommunityList Title</p></th>

			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Action</p></th>

			<th
				style="background-color: #778899; font-family: Arial; font-size: 20px"><p
					style="color: white;">Action</p></th> #{list items: ListPage,as:'FList'}
		</tr>
		<td>
			<ul>
				<li>
					<h2>${FList.name}</h2>
				</li>
			</ul> ${FList.id}</td>
		<!-- Begin @author Heidi ElToukhy a button to open a certain communityList and
			view a list of its members"-->
		<td>
			<form action="@{CommunityLists.commListContent()}" method="GET">
				<div id="${FList.id}">
					<button name="Open" type="submit" value="${FList.id}">Open</button>
				</div>
			</form>
		</td>
		<!-- End @author Heidi ElToukhy-->
		<td>
			<!-- Begin @author Nada button:ask to join --> #{if isReg == false }
			#{if
			!(models.RegisteredUser.findById(Long.parseLong(session.get("RegisteredUserId"))).CommunityLists.contains(models.CommunityList.findById(FList.id)))}
			#{if
			models.RegisteredUser.findById(Long.parseLong(session.get("RegisteredUserId")))!=
			models.CommunityList.findById(FList.id).creator}

			<form action="@{CommunityLists.askToJoin()}" method="GET">
				<div id="${FList.id}">
					<button name="join" type="submit" value="${FList.id}">ask
						to join</button>

				</div>

			</form> #{/if} #{/if} #{/if} <!-- End @author Nada-->
		</td> #{/list}
	</table>

	#{/if}
	<br>
	<form>
		<li><a href="@{Application.viewProfile()}">Back to Profile
				Page</a></li>
	</form>
	<br>

</body>
